package com.neteast.androidclient.newscenter.db;

import com.neteast.androidclient.newscenter.Global;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DbHelper extends SQLiteOpenHelper {
	
	public DbHelper(Context context) {
		super(context, Global.DB_NAME, null, Global.DB_VERSION);
	}
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE IF NOT EXISTS "+Global.TABLE_NAME_GUEST+
				"(_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
				"info_id BIGINT, " +
				"info_type_id INTEGER, " +
				"app_id INTEGER, " +
				"app_name TEXT," +
				"app_thumbnail_path TEXT," +
				"user_id BIGINT, " +
				"user_name TEXT," +
				"interactive_type INTEGER," +
				"send_time BIGINT," +
				"textContent TEXT," +
				"go_url TEXT," +
				"sys_pic_path TEXT)");
		
		db.execSQL("CREATE TABLE IF NOT EXISTS "+Global.TABLE_NAME_LOGIN_INFO+
				"(_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
				"userid INTEGER, " +
				"token TEXT)");
		
	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS "+Global.TABLE_NAME_GUEST);
		onCreate(db);
	}
}
